﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExamSystem.BLL;
using ExamSystem.Mdeol;
namespace ExamSystem.ht
{
    public partial class TPager_Edit : System.Web.UI.Page
    {
        private TpagerBLL tbl = new TpagerBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
         if(!Page.IsPostBack)
         {
             string id = Request.QueryString["id"];
             Tpager tp = tbl.selecttpid(int.Parse(id));
             if(tp!=null)
             {
                 this.tpName.Value = tp.TpName;
                 this.datemin.Value = tp.TpBeginTime;
                 this.datemax.Value = tp.TpEndTime;
             }
             else
             {
                 util.FunHelper.LayerAlter(this,"数据不存在","TPager_List.aspx");
             }
         }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                //获取数据
                string name = this.tpName.Value.Trim();
                string begin = this.datemin.Value;
                string end = this.datemax.Value;
                //验证
                if (string.IsNullOrEmpty(name))
                {
                    this.lbMsg.InnerText = "请输入试卷名称";
                    return;
                }
                if (string.IsNullOrEmpty(begin))
                {
                    this.lbMsg.InnerText = "请选择开始时间";
                    return;
                }
                if (string.IsNullOrEmpty(end))
                {
                    this.lbMsg.InnerText = "请选择结束时间";
                    return;
                }
                //入库
                this.lbMsg.InnerText = "";
                string id = Request.QueryString["id"];
                Tpager t = new Tpager(int.Parse(id), name, begin, end);
                tbl.update(t);
                util.FunHelper.LayerAlter(this, "修改成功", "TPager_List.aspx");
            }
            catch(Exception ex)
            {
                util.FunHelper.LayerAlter(this,ex+"");
            }
           
        }
    }
}